<?php

require_once 'data/datautils.php';

$salt = 'sigs';

if (!session_id())
    session_start();

function isAuth() {
    return isset($_SESSION['logged']);
}

function removeAuth() {
    unset($_SESSION['logged']);
}

function addAuth() {
    $_SESSION['logged'] = 1;
}

function checkCredentials($uname, $pass) {
	global $salt;
	$hash = md5($pass+$salt);
	$result = db_select_all_where('auth',"`uname` = '".db_escape($uname)."' AND `pass` = '".$hash."'");
	return count($result)>0; 
}